/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package atributos;

import java.io.File;
import java.io.FilenameFilter;
import java.util.*;
import java.util.TreeSet;

/**
 *
 * @author maldo
 */
public class Filter implements FilenameFilter{

    protected Set extensionesSet;

    public boolean accept(File dir, String name) {
        final Iterator exts = extensionesSet.iterator();
        while(exts.hasNext()){
            if(name.toLowerCase().endsWith(exts.next().toString())){
                return true;
            }
        }
        return false;
    }

    public Filter(String[] extensiones) {
        extensionesSet = new TreeSet();
        
        for(Iterator ext = Arrays.asList(extensiones).iterator(); ext.hasNext();){
            extensionesSet.add(ext.next().toString().toLowerCase().trim());
        }  
        extensionesSet.remove("");
    }

}
